package com.jrx.anytxn.customer.dto.customer.medical;

import com.jrx.anytxn.common.data.TxnRespCode;
import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnRuntimeException;
import com.jrx.anytxn.common.uitl.StringUtils;
import com.jrx.anytxn.customer.entity.CmCustomerLimitInfo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 信用就医业务，cms客户端发起冻结、解冻操作处理结果返回
 *
 * @author user
 * @date 2022/8/9 14:30
 */
public class CustomerLimitVerifyDto implements Serializable {

    private static final long serialVersionUID = -7052966390686842123L;

    private String productId;

    private String customerId;

    private String seqNo;

    private CmCustomerLimitInfo customerLimitInfo;

    private Date businessDate;

    private String tenantId;

    private BigDecimal amtToUse;

    private BigDecimal availCreditLimit;

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public String getSeqNo() {
        return seqNo;
    }

    public void setSeqNo(String seqNo) {
        this.seqNo = seqNo;
    }

    public CmCustomerLimitInfo getCustomerLimitInfo() {
        return customerLimitInfo;
    }

    public void setCustomerLimitInfo(CmCustomerLimitInfo customerLimitInfo) {
        this.customerLimitInfo = customerLimitInfo;
    }

    public Date getBusinessDate() {
        return businessDate;
    }

    public void setBusinessDate(Date businessDate) {
        this.businessDate = businessDate;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public BigDecimal getAmtToUse() {
        return amtToUse;
    }

    public void setAmtToUse(BigDecimal amtToUse) {
        this.amtToUse = amtToUse;
    }

    public BigDecimal getAvailCreditLimit() {
        return availCreditLimit;
    }

    public void setAvailCreditLimit(BigDecimal availCreditLimit) {
        this.availCreditLimit = availCreditLimit;
    }

    public void check(){
        if (StringUtils.isBlank(tenantId)){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"租户号为空");
        }
        if (StringUtils.isBlank(customerId)){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"客户号为空");
        }
        if (StringUtils.isBlank(productId)){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"产品号为空");
        }
        if (customerLimitInfo == null){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"客户-产品对应的额度信息为空");
        }
        if (businessDate == null){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"业务日期为空");
        }
        if (amtToUse == null){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"冻结/实时支付额度为空");
        }
        if (availCreditLimit == null){
            throw new TxnRuntimeException(TxnRespCode.PARAM_ERROR.getCode(),"客户--产品可用额度为空");
        }
    }
}
